﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QLKS
{
    public partial class frthemql : Form
    {
        public frthemql()
        {
            InitializeComponent();
        }

        private void btnthoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnthem_Click(object sender, EventArgs e)
        {
            try
            {
                dtpNTNS.Value = DateTime.MinValue;
                if (txttennv.Text == "" && txtdiachi.Text == "")
                {
                    MessageBox.Show("Ban chua nhap thong tin");
                }
                else
                {
                    DTO.CNHANVIEN ql = new DTO.CNHANVIEN();
                    ql.HoTen = txttennv.Text;
                    ql.DiaChi = txtdiachi.Text;
                    ql.NgaySinh = dtpNTNS.Value;
                    TimeSpan diff = DateTime.Now - ql.NgaySinh;
                    ql.Tuoi = (int)(diff.Days / 365);
                    ql.MaLoaiNhanVien = "ql";
                    if (!(BUS.XuLyNhanVien.ThemNhanVien(ql)))
                    {
                        MessageBox.Show("Co loi xay ra. Kiem tra lai file CSDL");
                    }
                    this.Close();
                }
            }
            catch (System.Exception )
            {
            	
            }
            
        }
    }
}
